package com.miaocat19.error;

/**
 * @program: Javamiaosha
 * @description:
 * @author: miaocat19
 * @create: 2021-12-08 18:26
 **/
public enum EmBusinessError implements CommonError {

    //1000开头是定义通用的参数
    PARAMETER_VALIDATION_ERROR(10001, "用户的参数不合法"),
    UNKNOWN_ERROR(10002, "未知错误"),


    //2000开头是定义用户的层级的错误
    USER_NOT_EXIST(20001, "用户不存在"),
    USER_LOGIN_FAIL(20002, "用户手机号或密码不正确"),
    USER_NOT_LOGIN(20003, "用户还没有登陆"),
    //30000开头为交易信息错误定义
    STOCK_NOT_ENOUGH(30001, "库存不足"),
    MQ_SEND_FAIL(30002, "MQ异步发送失败"),
    RATELIMIT(3002, "活动太火爆，请稍后再试");


    EmBusinessError() {

    }

    EmBusinessError(int errCode, String errMsg) {
        this.errCode = errCode;
        this.errMsg = errMsg;
    }

    private int errCode;
    private String errMsg;


    @Override
    public int getErrCode() {
        return this.errCode;
    }

    @Override
    public String getErrMsg() {
        return this.errMsg;
    }

    @Override
    public CommonError setErrMsg(String errMsg) {
        this.errMsg = errMsg;
        return this;
    }
}
